package com.ttg.common.dto;

import com.ttg.common.constant.ParentDateTypeConstant;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Objects;


/**
 * @author zhangHongYuan
 * @description
 * @date 2024/1/23 11:40
 */
public  class NumberDataType extends ParentDateTypeConstant{


    private static final long serialVersionUID = 2927631319083036772L;

    @Override
    public boolean between(BigDecimal value, BigDecimal start, BigDecimal end) {

        if (Objects.isNull(value)||Objects.isNull(start)||Objects.isNull(end)){
            return false;
        }

        if (value.compareTo(start)>-1 && value.compareTo(end)<0){
            return true;
        }
        return false;
    }

    @Override
    public boolean between() {
        return true;
    }
    @Override
    public boolean notBetween(BigDecimal value, BigDecimal start, BigDecimal end) {
        if (Objects.isNull(value)||Objects.isNull(start)||Objects.isNull(end)){
            return false;
        }

        if (value.compareTo(start)<0 || value.compareTo(end)>-1){
            return true;
        }
        return false;

    }

    @Override
    public boolean notBetween() {
        return true;
    }

    @Override
    public boolean equalTo(String value,String ratio) {
        if (StringUtils.isBlank(value)||StringUtils.isBlank(ratio)){
            return false;
        }
        BigDecimal a = BigDecimal.ZERO;
        BigDecimal b = BigDecimal.ZERO;

        try {
            a= new BigDecimal(value);
            b= new BigDecimal(ratio);
        }catch (Exception e){
            return false;
        }
        if (a.compareTo(b)==0){
            return true;
        }
        return false;
    }

    @Override
    public boolean equalTo() {
        return true;
    }

    @Override
    public boolean notEqualTo(String value,String ratio) {
        if (StringUtils.isBlank(value)||StringUtils.isBlank(ratio)){
            return false;
        }
        BigDecimal a = BigDecimal.ZERO;
        BigDecimal b = BigDecimal.ZERO;

        try {
            a= new BigDecimal(value);
            b= new BigDecimal(ratio);
        }catch (Exception e){
            return false;
        }
        if (a.compareTo(b)!=0){
            return true;
        }
        return false;

    }

    @Override
    public boolean notEqualTo() {
        return true;
    }

    @Override
    public boolean greaterThan(BigDecimal value, BigDecimal ratio) {
        if (Objects.isNull(value)||Objects.isNull(ratio)){
            return false;
        }

        if (value.compareTo(ratio)>0){
            return true;
        }

        return false;
    }

    @Override
    public boolean greaterThan() {
        return true;
    }

    @Override
    public boolean lessThan(BigDecimal value, BigDecimal ratio) {
        if (Objects.isNull(value)||Objects.isNull(ratio)){
            return false;
        }

        if (value.compareTo(ratio)<0){
            return true;
        }

        return false;
    }

    @Override
    public boolean lessThan() {
        return true;
    }

    @Override
    public boolean greaterThanEqualTo(BigDecimal value, BigDecimal ratio) {

        if (Objects.isNull(value)||Objects.isNull(ratio)){
            return false;
        }

        if (value.compareTo(ratio)>=0){
            return true;
        }

        return false;
    }

    @Override
    public boolean greaterThanEqualTo() {
        return true;
    }

    @Override
    public boolean lessThanEqualTo(BigDecimal value, BigDecimal ratio) {
        if (Objects.isNull(value)||Objects.isNull(ratio)){
            return false;
        }

        if (value.compareTo(ratio)<=0){
            return true;
        }

        return false;
    }

    @Override
    public boolean lessThanEqualTo() {
        return true;
    }


    @Override
    public boolean like() {
        return false;
    }
}
